Skip to content

Conversation

@qmadev
Copy link
Contributor

@qmadev qmadev commented Nov 10, 2025

closes #1331

Copy link
Contributor

@twiggler twiggler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests?

There are a lot of potential edge cases :)

# If we have a buffer with a timestamp and
# our current line also has a timestamp,
# we should have a complete record in our buffer.
if previous_ts := RE_TIMESTAMP_PATTERN.match(buf):
Copy link
Contributor

@twiggler twiggler Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This potentially causes memory exhaustion if the log file does not start with a timestamp.
(And no entries will get returned)

I think the logic I posted here does not suffer from that problem


# For the last line
if buf:
if current_ts := RE_TIMESTAMP_PATTERN.match(line):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works if the last line is timestamped. If it is text, it will fail and the last record will be dropped.

The solution is to use current_ts

@qmadev
Copy link
Contributor Author

qmadev commented Dec 4, 2025

@twiggler I took a second look at your logic but I could not get it to work. Had issues with messages that had newlines and tabs in it. I added a check to see if a logfile starts with a timestamp and skip it if it does not. Would be very weird for this log format.

Added some unit tests and changed the test file a little bit to make sure that the last log entry contains a newline which we can test on.

Lmk what u think.

@twiggler
Copy link
Contributor

@twiggler I took a second look at your logic but I could not get it to work. Had issues with messages that had newlines and tabs in it. I added a check to see if a logfile starts with a timestamp and skip it if it does not. Would be very weird for this log format.

Added some unit tests and changed the test file a little bit to make sure that the last log entry contains a newline which we can test on.

Lmk what u think.

Hi, can you share (parts of, and/or redacted) the logfile that leads to problems?

@qmadev
Copy link
Contributor Author

qmadev commented Dec 18, 2025

Try the test data file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSSQL incorrect timestamp parsing

2 participants